//  Brett Jones
//  PBR Senior Thesis
//  Copyright Brett Jones October 2007

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace PBR
{
    /// <summary>
    /// Holds the material attributes for the painting
    /// </summary>
    public class Material
    {
        #region Consts

        private const float DIFFUSECOEF = 0.1f;
        private const float SPECULARCOEF = 0.1f;
        private const float AMBIENTCOEF = 0.1f;
        private const float SHININESS = 0.2f;
        private const float VSCALE = 0.1f;
        private const float BASELINELENGTH = 40.0f;
        private const float EDGELINELENGTH = 15.0f;
        private const int EDGETHRESHABS = 200;
        private const int EDGETHRESHREL = 100;
        private const int EDGESCALEREL = 90;
        private const int OVERLAP = 100;
        private const int OPACITY = 90;
        private const int EDGELEVEL = 0;

        #endregion

        #region Member Variables

        private float mDiffuseCoef = DIFFUSECOEF;
        private float mSpecularCoef = SPECULARCOEF;
        private float mAmbientCoef = AMBIENTCOEF;
        public string Name;
        public Color Ambient = Color.White;
        public float Shininess = SHININESS;
        public float VScale = VSCALE;
        public float BaseStrokeLength = BASELINELENGTH;
        public float EdgeStrokeLength = EDGELINELENGTH;
        public byte EdgeThreshAbs = EDGETHRESHABS;
        public byte EdgeThreshRel = EDGETHRESHREL;
        public int EdgeLevel = EDGELEVEL;
        public int EdgeScaleRel = EDGESCALEREL;
        public int Overlap = OVERLAP;
        public int Opacity = OPACITY;
        
        #endregion

        #region Member Functions

        /// <summary>
        /// Creates a new material with 
        /// </summary>
        /// <param name="name"></param>
        public Material(string name)
        {
            this.Name = name;
        }

        /// <summary>
        /// Creates a new material that is a copy of the old one
        /// </summary>
        /// <param name="toCopy"></param>
        public Material(string name, Material toCopy)
        {
            Name = name;
            mDiffuseCoef = toCopy.mDiffuseCoef;
            mSpecularCoef = toCopy.mSpecularCoef;
            mAmbientCoef = toCopy.mAmbientCoef;
            Ambient = toCopy.Ambient;
            Shininess = toCopy.Shininess;
            VScale = toCopy.VScale;
            BaseStrokeLength = toCopy.BaseStrokeLength;
            EdgeStrokeLength = toCopy.EdgeStrokeLength;
            EdgeThreshAbs = toCopy.EdgeThreshAbs;
            EdgeThreshRel = toCopy.EdgeThreshRel;
            EdgeLevel = toCopy.EdgeLevel;
            EdgeScaleRel = toCopy.EdgeScaleRel;
            Overlap = toCopy.Overlap;
            Opacity = toCopy.Opacity;
        }

        #endregion

        #region Properties

        public float DiffuseCoef
        {
            get
            {
                return mDiffuseCoef;
            }
            set
            {
                if (value <= 0.0)
                    mDiffuseCoef = 0.0f;
                else if (value >= 1.0)
                    mDiffuseCoef = 1.0f;
                else
                    mDiffuseCoef = value;
            }
        }

        public float SpecularCoef
        {
            get
            {
                return mSpecularCoef;
            }
            set
            {
                if (value <= 0.0)
                    mSpecularCoef = 0.0f;
                else if (value >= 1.0)
                    mSpecularCoef = 1.0f;
                else
                    mSpecularCoef = value;
            }
        }

        public float AmbientCoef
        {
            get
            {
                return mAmbientCoef;
            }
            set
            {
                if (value <= 0.0)
                    mAmbientCoef = 0.0f;
                else if (value >= 1.0)
                    mAmbientCoef = 1.0f;
                else
                    mAmbientCoef = value;
            }
        }

        #endregion
    }
}
